#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"
void menu()
{
	printf("**********************************\n");
	printf("**********   1.play     ***********\n");
	printf("**********   0.exit     **********\n");
	printf("**********************************\n");
	printf("**********************************\n");

}
void game()
{
	char board[ROW][COL] = { 0 };//创建数组

	InitBoard(board, ROW, ROW);//初始化数组为空格

	char ret = 0;

	while (1)
	{
		DisyplayBoard(board, ROW, COL);//打印棋盘

		PlayerMove(board, ROW, COL);//玩家下棋

		ret=IsWin(board, ROW, COL);//判断输赢
		if (ret != 'C')
			break;

		ComputerMove(board, ROW, COL);//电脑玩家下棋

		ret = IsWin(board, ROW, COL);//判断输赢
		if (ret != 'C')
			break;
	}
	if (ret == '*')
		printf("玩家获胜\n");
	else if (ret == '#')
		printf("电脑获胜\n");
	else
		printf("平局\n");
}
int main()
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
		menu();//菜单
		printf("请选择：");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			game();
			break;
		case 0:
			printf("退出游戏\n");
			break;
		default:       //选的不是1也不是0，说明选错了
			printf("选择错误，请重新选择\n");
				break;
		}
	} while(input);
	return 0;
}